package cn.gd.my.servlet;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/FirstServlet")
public class FirstServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void init(ServletConfig config) throws ServletException {
		System.out.println("Invoke Servlet init() method...");
	}


	public void destroy() {
		System.out.println("Invoke Servlet Destroy() method...");
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("Invoke Servlet doGet() method...");
		doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("Invoke Servlet doPost() method...");
		String[] str = {"This"," is"," JSTL"," Test"," Sample!"};
		request.setAttribute("jstl", str);
		request.setAttribute("loopTimes", 7);
		request.getRequestDispatcher("index.jsp").forward(request, response);
		//getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
	}

}
